<?php
            $this->headTitle($this->title);
             $this->headScript()->appendFile(Zend_Registry::get('static_path').'js/users.js');
            $this->headLink()->appendStylesheet(Zend_Registry::get('static_path').'css/user.css');
            $this->layout()->setLayout('userlayout');
?>
<div class="nav"><a href="<?php echo $this->url(array( 'controller' => 'resident', 'action'     => 'index'),'default', true) ?>" class="navlink">Control Panel</a><img src="../images/arrow.gif" class="arrow"/> Manage Profile</div>
<div id="userForm">
    <div id="form-container1">
                  <?php
                          if($this->data !=null){?>
                              <form name="profile" id="profile"   class="form" action="<?php echo $this->url(array( 'controller' => 'user', 'action'     => 'profile'),'default', true) ?>" method="post">
                               <table class="dataTable">
                                   <tbody>
                                       <tr>
                                           <td colspan="2" align="center"><?php echo $this->message?></td>
                                       </tr>
                                       <tr>
                                           <td width="20%">
                                               <label>Email Address:</label>
                                           </td>
                                            <td>
                                                <b><?php echo $this->data->getEmailAddress() ?></b>
                                            </td>
                                       </tr>
                                       <tr>
                                           <td width="20%">
                                               <label>First Name:<img src="../images/redStar.gif"/></label>
                                           </td>
                                            <td>
                                                <input type="text" name="firstName"  id="firstName"  value="<?php echo $this->data->getFirstName()?>"  size="30" maxlength="30">&nbsp;&nbsp;&nbsp;<span id="firstNameError" class="error"></span>
                                            </td>
                                       </tr>
                                        <tr>
                                            <td width="20%">
                                                <label>Last Name:<img src="../images/redStar.gif"/></label>
                                            </td>
                                            <td>
                                                <input type="text" name="lastName"  id="lastName" value="<?php echo $this->data->getLastName()?>"  size="30" maxlength="30">&nbsp;&nbsp;&nbsp;<span id="lastNameError" class="error"></span>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td width="20%">
                                                <label>Address Line 1:</label>
                                            </td>
                                             <td>
                                                 <input type="text" name="address1"  size="50" value="<?php echo $this->data->getAddress1()?>" maxlength="50">
                                             </td>
                                        </tr>
                                        <tr>
                                            <td width="20%">
                                                <label>Address Line 2:</label>
                                            </td>
                                            <td>
                                                <input type="text" name="address2" size="50" value="<?php echo $this->data->getAddress2()?>"  maxlength="50">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td width="20%">
                                                <label>City:</label>
                                            </td>
                                            <td>
                                                <input type="text" name="city" maxlength="20" value="<?php echo $this->data->getCity()?>" >
                                            </td>
                                        </tr>
                                        <tr>
                                            <td width="20%">
                                                <label>State:</label>
                                            </td>
                                            <td>
                                                <select id="state" name="state" ></select>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td width="20%">
                                                <label>Country:</label>
                                            </td>
                                             <td>
                                                 <select id="country" name="country" ></select>
                                             </td>
                                          </tr>
                                          <tr>
                                              <td width="20%">
                                                  <label>Zip:</label>
                                              </td>
                                              <td>
                                                  <input type="text" name="zip" maxlength="5" size="6" value="<?php echo $this->data->getZip()?>">
                                              </td>
                                        </tr>
                                        <tr>
                                            <td width="20%">
                                                <label>Phone Number 1:</label>
                                            </td>
                                            <td>
                                                <input type="text" name="phone1" maxlength="20" value="<?php echo $this->data->getPhone1()?>"  size="11">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td width="20%">
                                                <label>Phone Number 2:</label>
                                            </td>
                                            <td>
                                                <input type="text" name="phone2" maxlength="20" size="11" value="<?php echo $this->data->getPhone2()?>">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td width="20%">
                                                <label>Cell:</label>
                                            </td>
                                            <td>
                                                <input type="text" name="cell" maxlength="20" size="11" value="<?php echo $this->data->getCell()?>">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td width="20%">
                                                <label>Email 2:</label>
                                            </td>
                                            <td>
                                                <input type="text" name="email2"  size="30" maxlength="30" value="<?php echo $this->data->getEmail2()?>">
                                            </td>
                                        </tr>
                                         <tr>
                                                <td colspan="2" align="center">
                                                    <input type="button" id="saveProfile" value="Submit"/>&nbsp;&nbsp;<input type="button" id="cancel"  value="Cancel"/>
                                                </td>
                                            </tr>
                                   </tbody>
                               </table>
                                <input type="hidden" id="_country" value="<?php echo $this->data->getCountry()?>"/>
                                <input type="hidden" id="_state" value="<?php echo $this->data->getState()?>"/>
                                <input type="hidden" id="userId" name="userId" value="<?php echo $this->data->getUserId()?>"/>
                                <input type="hidden" id="emailAddress"   name="emailAddress" value="<?php echo $this->data->getEmailAddress()?>"/>
                                 <input type="hidden" name="action" value="_save"/>
                           </form>
                         <?php     }  ?>
   </div>
</div>
<script>
 $(document).ready(function(){
      $.getJSON("../process/country", function(call){
         var selected="";
         $.each(call, function(key, value){
             if(key==$("#_country").val()){selected = "selected"}else{selected =""};
          $("#country").append('<option value="'+key+'" '+selected+'>'+value+'</option>');
        });
     });

   $.getJSON("../process/state", function(call){
         var selected="";
         $.each(call, function(key, value){
             if(key==$("#_state").val()){selected = "selected"}else{selected =""};
          $("#state").append('<option value="'+key+'" '+selected+'>'+value+'</option>');
        });
     });

     $("#cancel").click(function(){
            window.location="<?php echo $this->url(array( 'controller' => 'resident', 'action'     => 'index'),'default', true) ?>";
     });
 });
 </script>


